﻿using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WebApi.Bill.Biz;

namespace WebApi.Controllers
{
    public class WeatherController : BaseController
    {

        #region 获取实时天气信息
        /// <summary>
        /// 根据编码获取单条数据
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        [HttpGet]
        public ActionResult<ResponseData> GetWeatherInfo(string location)
        {
            ResponseData res = new ResponseData();
            try
            {
              
                dynamic  data = BizBase.Get<BizWeather>().GetWeatherInfo(location);

                res.ErrorCode = 0;
                res.Message = "Success";
                res.DataList = new ModelData
                {
                    TotalPage = 0,
                    DataList = data
                };
                return new JsonResult(res);
            }
            catch (Exception ex)
            {
                return this.ControllerExHandler(res, "GetWeatherInfo", ex);
            }
        }
        #endregion


        #region 获取7天气信息
        /// <summary>
        /// 根据编码获取单条数据
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        [HttpGet]
        public ActionResult<ResponseData> Get7DaysWeatherInfo(string location)
        {
            ResponseData res = new ResponseData();
            try
            {

                dynamic data = BizBase.Get<BizWeather>().Get7DaysWeatherInfo(location);

                res.ErrorCode = 0;
                res.Message = "Success";
                res.DataList = new ModelData
                {
                    TotalPage = 0,
                    DataList = data
                };
                return new JsonResult(res);
            }
            catch (Exception ex)
            {
                return this.ControllerExHandler(res, "Get7DaysWeatherInfo", ex);
            }
        }
        #endregion
    }
}
